﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Entities;
using static Entities.TestEntities;
using System.Linq.Expressions;

namespace ExpressionTest
{
    public class ExpressionDemo
    {
       public static void Go()
       {
           Expression<Func<Product, int>> exp = x => x.Price*200;
           int p = exp.Compile().Invoke(TestProducts.Products.Where(x => x.Price == 100).FirstOrDefault());
           Console.WriteLine(p);

           Expression<Func<Product, string, bool>> exp2 = (x, y) => x.ProductName == y && x.Price > 100 && x.IsDelete == 0;
           List<Product> products =
               TestProducts.Products.Where(x => exp2.Compile()(x, "product1")).AsQueryable().ToList();

           
       }
    }
}
